package nc.ui.qc.c011.billref.c012;

import org.apache.commons.lang3.ArrayUtils;

import nc.bs.framework.common.NCLocator;
import nc.itf.qc.c011.IQueryC011ForC012;
import nc.ui.pubapp.uif2app.query2.model.IRefQueryService;
import nc.ui.querytemplate.querytree.IQueryScheme;
import nc.vo.ic.m46.entity.FinProdInBodyVO;
import nc.vo.ic.m46.entity.FinProdInVO;
import nc.vo.pu.m23.entity.ArriveItemVO;
import nc.vo.pu.pub.util.VOSortUtils;
import nc.vo.pub.BusinessException;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.qc.c011.entity.AggMetApplyHeaderVO;
import nc.vo.qc.c011.entity.MetApplyItemVO;

public class RefQueryServiceForC012 implements IRefQueryService {

	@Override
	public Object[] queryByQueryScheme(IQueryScheme queryScheme) {
		AggMetApplyHeaderVO[] rets = null;
		IQueryC011ForC012 service = NCLocator.getInstance().lookup(IQueryC011ForC012.class);
		try {
			rets = service.queryMetApply(queryScheme);
			if (!ArrayUtils.isEmpty(rets)) {
				for (AggMetApplyHeaderVO vo : rets) {
					MetApplyItemVO[] itemVOs = vo.getItemVO();
					VOSortUtils.ascSort(itemVOs, "crowno");
					vo.setChildrenVO(itemVOs);
				}
			}
		} catch (BusinessException e) {
			ExceptionUtils.wrappException(e);
		}
		return rets;
	}

	@Override
	public Object[] queryByWhereSql(String paramString) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}
}
